import React from "react";

class Mouse extends React.Component {
    state = {
        x:0,
        y:0
    }
    handlerState=(e)=>{
        this.setState({
            x: e.clientX,
            y: e.clientY
        })
    }
    componentDidMount(){
        window.addEventListener('mousemove', this.handlerState)
    }
    componentWillUnmount(){
        window.removeEventListener('mousemove', this.handlerState)
    }
    render(){
        return this.props.children(this.state)
    }
}

export default Mouse